﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HikVisionTool.Helper
{
    public class Sql3Helper
    {
        private ConnectionConfig connection = null;
        public SqlSugarClient db = null;
        public Sql3Helper()
        {
            string SqlIP = "192.168.2.3";
            string database = "MESDB";
            string uid = "sa";
            string pwd = "8ik,9ol.";
            connection = new ConnectionConfig()
            {
                ConnectionString = "server='" + SqlIP + "';initial catalog='" + database + "';uid='" + uid + "';pwd='" + pwd + "'",
                DbType = DbType.SqlServer,
                IsAutoCloseConnection = true,
                InitKeyType = InitKeyType.Attribute
            };
            db = new SqlSugarClient(connection);
        }
        public bool SqlCheck()
        {
            try
            {
                db.Open();
                db.Close();
                db.Dispose();
                return true;
            }
            catch (Exception ee)
            {
                return false;
            }
        }

        #region t_HK_checkdta
        [SugarTable("t_HK_checkdta")]
        public class t_HK_checkdta
        {
            public string pk_id { get; set; }
            public string lifnr { get; set; }
            public string wknum { get; set; }
            public string barcd { get; set; }
            public string pline { get; set; }
            public string processid { get; set; }
            public string funct { get; set; }
            public string wkposition { get; set; }
            public DateTime ck_start_dt { get; set; }
            public DateTime ck_end_dt { get; set; }
            public string crname { get; set; }
            public DateTime crtime { get; set; }
            public string filename { get; set; }
            public string update_flag { get; set; }
            public int status { get; set; }
            public string stream { get; set; }
        }
        #endregion
        #region t_HK_checkdta_detail_first
        [SugarTable("t_HK_checkdta_detail_first")]
        public class t_HK_checkdta_detail_first
        {
            [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
            public long id { get; set; }

            public string pk_id { get; set; }

            public string lifnr { get; set; }

            public int seqfid { get; set; }

            public string ck_item_name { get; set; }

            public string ck_item_desc { get; set; }

            public string funct { get; set; }

            public DateTime ck_start_dt { get; set; }

            public DateTime ck_end_dt { get; set; }

            public string crname { get; set; }

            public DateTime crtime { get; set; }

            public int status { get; set; }

            public string update_flag { get; set; }

        }
        #endregion
        #region t_HK_checkdta_detail_second
        [SugarTable("t_HK_checkdta_detail_second")]
        public class t_HK_checkdta_detail_second
        {
            [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
            public long id { get; set; }

            public string pk_id { get; set; }

            public string lifnr { get; set; }

            public int seqfid { get; set; }

            public int seqsid { get; set; }

            public string ck_item_type { get; set; }

            public string ck_item_name { get; set; }
            public string ck_item_desc { get; set; }

            public string funct { get; set; }

            public DateTime ck_start_dt { get; set; }

            public DateTime ck_end_dt { get; set; }

            public string crname { get; set; }

            public DateTime crtime { get; set; }

            public string update_flag { get; set; }

            public int status { get; set; }

        }
        #endregion
        #region t_HK_workorder_barcode_status
        [SugarTable("t_HK_workorder_barcode_status")]
        public class t_HK_workorder_barcode_status
        {
            [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
            public long id { get; set; }
            public string barcd { get; set; }
            public string wknum { get; set; }
            public string next_pline { get; set; }
            public string next_processid { get; set; }
            public string processid { get; set; }
            public DateTime arrivetime { get; set; }
            public string chname { get; set; }
            public DateTime chtime { get; set; }
            public int status { get; set; }
        }
        #endregion

        #region t_DD_UserDetail
        [SugarTable("t_DD_UserDetail")]
        public class t_DD_UserDetail
        {
            public string username { get; set; }
            public string jobnumber { get; set; }
            public string companyName { get; set; }
        }
        #endregion
    }
}